package com.JustTest;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.lang.Nullable;
import org.springframework.util.StringValueResolver;

/**
 * Created by mike on 18/2/7.
 */
public class MyEmbeddedValueResolverAware implements EmbeddedValueResolverAware ,BeanPostProcessor {
    private StringValueResolver resolver = null;
    @Override
    public void setEmbeddedValueResolver(StringValueResolver stringValueResolver) {
        this.resolver = stringValueResolver;
    }

    public String getPropertiesValue(String name) {
        return resolver.resolveStringValue(name);
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
